package com.emperor.course.app;

import java.util.Map;

import org.apache.log4j.Logger;

import com.emperor.core.app.App;
import com.emperor.core.app.AppConstant;
import com.emperor.core.app.AppCtrl;

public class CourseAppCtrl implements AppCtrl {

	public static final String COURSE_CTRL = "course.ctrl";
	public static final String COURSE_NEW = "course.new";
	public static final String COURSE_MGM = "course.mgm";
	public static final String COURSE_MOV = "course.mov";
	public static final String COURSE_ENQ = "course.enq";
	public static final String COURSE_DEL = "course.del";
	public static final String COURSE_PRODENQ = "course.prodenq";
	public static final String COURSE_PRODNEW = "course.prodnew";
	public static final String COURSE_PRODMGM = "course.prodmgm";
	public static final String COURSE_PRODDEL = "course.proddel";
	public static final String COURSE_TREATENQ = "course.treatenq";
	public static final String COURSE_TREATNEW = "course.treatnew";
	public static final String COURSE_TREATMGM = "course.treatmgm";
	public static final String COURSE_TREATDEL = "course.treatdel";
	
	public static final String COURSE_MSG = "course.msg";
	public static final String COURSE_ID = "course.id";
	public static final String PROD_ID = "prod.id";
	public static final String TREATMENT_ID = "treatment.id";
	public static final String COURSEPROD_ID = "courseprod.id";
	public static final String COURSETREAT_ID = "coursetreat.id";
	public static final String COURSE_LIST = "course.list";
	public static final String COURSE_ACTIONNAME = "course.actionname";
	
	public static Logger log = Logger.getLogger(CourseAppCtrl.class);
	
	@Override
	public void doProcess(Map<String, Object> params) {
			App app = null;
			if (params == null) {
				log.error("Param is null");
			} else if (params.get(AppConstant.ACTION).equals(COURSE_MGM)) {
				app = new CourseAppMgm(params);
			} else if (params.get(AppConstant.ACTION).equals(COURSE_NEW)) {
				app = new CourseAppNew(params);
			} else if (params.get(AppConstant.ACTION).equals(COURSE_PRODENQ)) {
				app = new CourseProdAppEnq(params);
			} else if (params.get(AppConstant.ACTION).equals(COURSE_TREATENQ)) {
				app = new CourseTreatAppEnq(params);
			} else {
				app = new CourseAppEnq(params);
			}
			
			if (app != null) {
				app.open();
			}
	}

}
